<template>
  <div>
    <p v-html="html"></p>
  </div>
</template>

<script>
import axios from 'axios'
export default {
  props: {
    url: {
      require: true
    }
  },
  data () {
    return {
      loading: false,
      html: ''
    }
  },
  mounted() {
    this.load(this.url)
  },
  methods: {
    load(url) {
      if (url && url.length > 0) {
        this.loading = true
        let param = {
          accept: 'text/html, text/plain'
        }
        axios.get(url, param).then(res => {
          this.html = res.data
        }).catch(() => {
          this.html = '加载内容失败'
        }).finally(() => {
          this.loading = false
        })
      }
    }
  }
}

</script>

<style lang='stylus' scoped>

</style>
